﻿@using Storage.Mapping.AppStorage
@using Storage.Core.Librs
@model AppStorageMapping
@{
    ViewBag.Title = "编辑应用信息";
}
 
    <h1>@ViewBag.Title</h1>
    <hr />

    <div class="row">
        <div class="col-sm-12">
            @using (Html.BeginRouteForm("editAppStorage", new { returnUrl = ViewBag.ReturnUrl }, FormMethod.Post, new { @class = "form-horizontal" , enctype = "multipart/form-data" }))
            {
                @Html.HiddenFor(m => m.Id)
                @Html.AntiForgeryToken()
                @Html.ValidationSummary(true,"")
                <div class="form-group">
                    <label class="col-sm-2 control-label no-padding-right">@RequiredSpan()应用名称</label>
                    <div class="col-sm-2">
                        @Html.TextBoxFor(m => m.Name, new { @class = "form-control", placeholder = "请输入系统名称" })
                        @Html.ValidationMessageFor(m => m.Name)
                    </div>
                </div>
                if (Model.Id == Guid.Empty)
                {
                    <div class="form-group">
                        <label class="col-sm-2 control-label no-padding-right">@RequiredSpan()根目录</label>
                        <div class="col-sm-2">
                            @Html.TextBoxFor(m => m.RootDirectory, new { @class = "form-control", placeholder = "请输入文件根目录" })
                            @Html.ValidationMessageFor(m => m.RootDirectory)
                        </div>
                    </div>
                }
                else
                {
                    <div class="form-group">
                        <label class="col-sm-2 control-label no-padding-right">根目录</label>
                        <div class="col-sm-9">
                            @Html.HiddenFor(m => m.RootDirectory)
                            <b>@Model.RootDirectory</b>
                        </div>
                    </div>
                }
                <h4 class="header blue bolder smaller">水印设置</h4>
                <div class="form-group">
                    <label class="col-sm-2 control-label no-padding-right">@RequiredSpan()水印类型</label>
                    <div class="radio">
                        @foreach (var item in Enum.GetValues(typeof(EnumWaterType)))
                        {
                            <label>
                                <input type="radio" class="ace" name="WaterType" @((int)item==Model.WaterType?"checked=checked":"") value="@((int)item)" />
                                <span class="lbl"> @item</span>
                            </label>
                        } 
                    </div>
                </div>
                <div class="form-group">
                    <label class="col-sm-2 control-label no-padding-right">@RequiredSpan()水印位置</label>
                    <div class="radio">
                        @foreach (var item in Enum.GetValues(typeof(WaterPosition)))
                        {
                            <label>
                                <input type="radio" class="ace" name="Position"@((int)item==Model.Position?"checked=checked":"")  value="@((int)item)" />
                                <span class="lbl"> @item</span>
                            </label>
                        }
                    </div>
                </div>
                <div class="form-group">
                    <label class="col-sm-2 control-label no-padding-right">@RequiredSpan()透明度</label>
                    <div class="col-sm-1">
                        <input class="form-control" data-val="true" data-val-number="必须是一个数字。"
                                data-toggle="tooltip" data-placement="right" title="数值越小越透明。值：0-100"
                               data-val-regex="只能输入0-100的数子" data-val-regex-pattern="^0|100|([1-9]\d*)$" data-val-required="字段是必需的。" id="Opacity" name="Opacity" value="@Model.Opacity" type="text">
                        @Html.ValidationMessageFor(m => m.Opacity)
                    </div> 
                </div>
                <h4 class="header blue bolder smaller">文字水印相关设置</h4>
                <div class="form-group">
                    <label class="col-sm-2 control-label no-padding-right">水印文字 </label>
                    <div class="col-sm-3">
                        @Html.TextBoxFor(m => m.FontText, new { @class = "form-contro", placeholder = "请输入水印的文字" })
                        @Html.ValidationMessageFor(m => m.FontText)
                    </div>
                </div>
                        <div class="form-group">
                            <label class="col-sm-2 control-label no-padding-right">字体大小</label>
                            <div class="col-sm-3">
                                @Html.TextBoxFor(m => m.FontSize, new { @class = "form-contro", placeholder = "请输入文字的大小。px单位" })
                                @Html.ValidationMessageFor(m => m.FontSize)
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="col-sm-2 control-label no-padding-right">字体</label>
                            <div class="col-sm-3">
                                @Html.TextBoxFor(m => m.FontFamily, new { @class = "form-contro", placeholder = "请输入文字的字体" })
                                @Html.ValidationMessageFor(m => m.FontFamily)
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="col-sm-2 control-label no-padding-right">字体</label>
                            <div class="col-sm-3">
                                @Html.TextBoxFor(m => m.FontColor, new { @class = "form-contro", placeholder = "字体颜色" })
                                @Html.ValidationMessageFor(m => m.FontColor)
                            </div>
                        </div>
                        <h4 class="header blue bolder smaller">图片水印相关设置</h4>
                        <div class="form-group">
                            <label class="col-sm-2 control-label no-padding-right">图片选择</label>
                            <div class="col-sm-3">
                                <input type="file" class="form-control"name="file" id="id-input-file-2">
                                <span>水印类型为图片时必须上传图片文件</span>
                            </div>
                        </div>

                        <div class="col-md-offset-2 col-md-9">
                            <button class="btn btn-info" type="submit">
                                <i class="ace-icon fa fa-check bigger-110"></i>
                                提交
                            </button>
                        </div>
            }
        </div>
    </div> 
<script>
    $(function () {
        $('[data-toggle="tooltip"]').tooltip();

        $('form').submit(function (e) {
            e.preventDefault();
            if($(this).valid()){
                $.modal.show();
                $(this).ajaxSubmit(function (data) {
                    $.modal.gritter(data, function () {
                        window.location.href = '/admin/home#page' + '@Url.RouteUrl("asppSorageIndex")';
                    });
                });
             }
        });
         


    })
</script>